package com.ww.springboot.boot.javabase.intern;

/**
 * @author wanwei
 * @since 2021-02-05 14:55
 */
public class StringDemo5 {

    public static void main(String[] args) {
        //
        String a = "计算";
        String b = "机";
        String c = "技术";
        String s3 = new StringBuilder(a).append(b).append(c).toString();
        String s4 = new StringBuilder("计算").append("机技术").toString();
        String s6 = s3.intern();
        String s5 = "计算机技术";
        //两个都是常量池
        System.out.println(s3.intern() == s5);
        System.out.println(s6 == s5);
        System.out.println(s3 == s5);
        System.out.println(s4.intern() == s5);
        System.out.println(s4 == s5);
        System.out.println(s3 == s4);

    }
}
